package com.maxd.controller.area;

import com.maxd.adapter.IgnoreSecurity;
import com.maxd.bean.area.AreaInfoTree;
import com.maxd.error.Result;
import com.maxd.error.ResultUtil;
import com.maxd.model.AreaInfo;
import com.maxd.service.area.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private IAreaService areaService;

    @IgnoreSecurity
    @GetMapping("/provence-list")
    public Result<List<AreaInfo>> provenceList() {
        return ResultUtil.success(areaService.provenceList());
    }

    @IgnoreSecurity
    @GetMapping("/provence-info")
    public Result<AreaInfoTree> provenceInfo(@RequestParam("areaCode") String areaCode) {
        return ResultUtil.success(areaService.provenceInfo(areaCode));
    }

}
